home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGBLER / WHIZZARD.LZH / CLREOS.ASM < prev    next >
Assembly Source File  |  1983-06-27  |  4KB  |  171 lines

  1. COMMENT *
  2.  
  3.                  CLUBware  (tm)
  4.  
  5.       CLREOS clears the screen from the current position to the end
  6.           of the screen.  Cursor is left at starting
  7.           position.
  8.  
  9.            Copyright 1984 Rayhawk Automation N.W. Inc
  10.                   P.O. Box 1427
  11.                   Beaverton, Oregon   97075
  12.  
  13.  
  14.       Algorithm:
  15.           1) load type of crt display from 0000:463
  16.           2) turn off crt display
  17.           3) load current position from 0000:0450
  18.           4) determine number of blanks to end of screen
  19.           5) do repeated store into screen buffer to blank area
  20.           6) reactive crt display
  21.  
  22.  
  23.       CALL      CLREOS ( FLAG% )
  24.  
  25.           FLAG%       environment flag
  26.                   = 0 means under basic interpreter
  27.                   = 1 means under compiled basic
  28.                   = 2 means under compiled business basic
  29.  
  30.                                           *
  31.  
  32. ;______________________________________________________________________________
  33.  
  34. ;  Normal assembly directives
  35.  
  36. CODE      SEGMENT PARA PUBLIC 'CODE'
  37.  
  38.       ASSUME  CS:CODE
  39.  
  40.       PUBLIC  CLREOS
  41.  
  42. ENV_FLAG      EQU  WORD PTR [BP+6] ; address of environment flag on stack
  43.  
  44. ;______________________________________________________________________________
  45.  
  46. CLREOS      PROC      FAR
  47.  
  48.       PUSH      AX               ; save all registers used,
  49.       PUSH      BX
  50.       PUSH      CX
  51.       PUSH      DX
  52.       PUSH      DI
  53.       PUSH      ES
  54.  
  55.  
  56.  
  57. ;      ...      1) load type of crt display from 0000:463
  58.  
  59.       SUB      AX,AX              ; address system area
  60.       MOV      ES,AX
  61.  
  62.       MOV      DX,WORD PTR ES:[463h]      ; load address of display adapter
  63.  
  64.  
  65.  
  66. ;      ...      2) turn off crt display
  67. ;             if this is a graphic display, wait for vertical retrace
  68.  
  69.       ADD      DX,4               ; addres crt control port
  70.  
  71.       CMP      DX,3D8h           ; graphic card?
  72.       JNE      NOT_GRAPHIC
  73.  
  74.       ADD      DX,2               ; address crt status port
  75. VERT_RETRACE:
  76.       IN      AL,DX            ; wait for vertical retrace
  77.       TEST      AL,8
  78.       JZ      VERT_RETRACE
  79.       SUB      DX,2               ; address crt mode port
  80.  
  81. NOT_GRAPHIC:
  82.  
  83.       MOV      AL,21h           ; turn off the video signal
  84.       OUT      DX,AL
  85.  
  86.  
  87. ;      ...      3) load environment flag showing compiled or interpreted
  88.  
  89.       MOV      BX,ENV_FLAG           ; load address of environment flag
  90.  
  91.  
  92. ;      ...      4) load current position from 0000:0450 if compiled
  93. ;              or from DS:[0056h] if interpreted
  94.  
  95.  
  96.       CMP      WORD PTR DS:[BX],0       ; check environment flag
  97.       JNE      COMPILED
  98.  
  99.       MOV      CX,WORD PTR DS:[0056h]   ; load from basic space
  100.       XCHG      CL,CH            ; basic has it reversed
  101.       DEC      CL               ; basic starts count from 1
  102.       DEC      CH               ;  instead of zero
  103.       JMP      SHORT HAVE_POSITION
  104.  
  105. COMPILED:
  106.       MOV      CX,WORD PTR ES:[450h]    ; load current position
  107.                        ;  from system space
  108. HAVE_POSITION:
  109.  
  110.       SUB      AH,AH            ; isolate row number in AX
  111.       MOV      AL,CH
  112.       MOV      BL,80            ; multiply row by 80 bytes per row
  113.       MUL      BL
  114.       SUB      CH,CH            ; add in column number
  115.       ADD      AX,CX
  116.  
  117.       MOV      DI,AX
  118.       SHL      DI,1               ; multiply by 2 to account
  119.                        ;  for attribute bytes
  120.  
  121.  
  122.  
  123. ;      ...      5) determine number of blanks to end of screen
  124.  
  125.       MOV      CX,2000           ; 2000 chars on entire screen
  126.       SUB      CX,AX            ; cx now holds number of blanks
  127.  
  128.  
  129.  
  130. ;      ...      6) do repeated store into screen buffer to blank area
  131.  
  132.       MOV      AX,0B000h           ; screen seg for monochrome card
  133.       CMP      DX,03D8h           ; is this a graphic card?
  134.       JNE      MONOCHROME
  135.  
  136.       MOV      AX,0B800h           ; load screen seg for graphic card
  137.  
  138. MONOCHROME:
  139.  
  140.       MOV      ES,AX            ; address the screen buffer
  141.       MOV      AX,0720h           ; AH = 07 ( normal video attribute
  142.                        ; AL = 20 ( blank
  143.       REP      STOSW            ; store CX blanks
  144.  
  145.  
  146.  
  147. ;      ...      7) reactive crt display
  148.  
  149.  
  150.       MOV      AL,29h           ; DX already has correct port
  151.       OUT      DX,AL
  152.  
  153.  
  154.  
  155.       POP      ES
  156.       POP      DI
  157.       POP      DX
  158.       POP      CX
  159.       POP      BX
  160.       POP      AX
  161.       RET      2
  162.  
  163.  
  164. CLREOS      ENDP
  165.  
  166. ;______________________________________________________________________________
  167.  
  168. CODE      ENDS
  169.  
  170.       END
  171.